import 'dart:developer';

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:guochaoapp/common/widges/appbar.dart';
import 'package:guochaoapp/controller/mine/setting_controller.dart';

class GCSettingPage extends StatelessWidget {

  GCSettingController c = Get.put(GCSettingController());

  @override
  Widget build(BuildContext context) {
    c.getVersion();
    return Scaffold(
      appBar: GCAppBar(titleText: "设置"),
        body: _initSubviews()
    );
  }

  _initSubviews() {
    return
      ListView(
      children: [
        ListView.builder(
          shrinkWrap: true,
          physics: NeverScrollableScrollPhysics(),
          itemCount: c.images.length,
          itemBuilder: (context, index) {
            return _itemView(c.images[index], c.titles[index], () => c.didSelectedIndex(index));
          },
        ),
        Container(child: Center(child: Text("版本号: ${c.getVersion()}")), height: 300,),
      ],
    );
  }

  _itemView(String imageNamed, String title, Function itemTap) {
    return GestureDetector(
      onTap: itemTap,
      child: Container(
        color: Colors.white,
        height: 43,
        child: Column(
          children: [
            Expanded(
              child: Row(children: [
                SizedBox(width: 20),
                Image.asset(imageNamed, width: 20, height: 20),
                SizedBox(width: 14),
                Text(title,
                    style: TextStyle(
                        color: Color(0xFF666666),
                        fontSize: ScreenUtil().setSp(14),
                    )),
                Expanded(child: SizedBox()),
                Icon((Icons.chevron_right),size: 14,color: Color(0xFF666666)),
                SizedBox(width: 28),
              ],
              ),
            ),
            Container(height: 1, color: Color(0xFFF4F8FE))
          ],
        ),
      ),
    );
  }
}
